<template>
  <div>
    <h2>{{ this.$route.query.text }}</h2>
    <div class="foot">
      <div
        class="box"
        v-for="item in list"
        :key="item.id"
        @click="jumpOne(item.id)"
      >
        <div class="imgbox">
          <img :src="item.titleImage" alt="" />
        </div>
        <div class="content">
          <h1>{{ item.title }}</h1>
          <p>{{ item.description }}</p>
          <p class="tag">
            <el-tag v-for="it in item.tags" :key="it.id">{{ it.name }}</el-tag>
          </p>
        </div>
      </div>
    </div>
    <el-pagination
      layout="prev, pager, next"
      :total="total"
      :page-size="10"
      @current-change="handleCurrent"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      page: 1,
      total: 0,
      id: "",
    };
  },
  created() {
    // console.log(this.$route.query,'1212121212121');
    this.id = this.$route.query.tagId;
    this.indexList();
    this.seek();
  },
  methods: {
    seek() {
      this.$emit("back", [true, false]);
    },
    //首页图文接口
    indexList() {
      this.$axios
        .post("http://47.104.167.34:9110/api/tag/article/list", {
          current: this.page,
          size: 10,
          tagId: this.id,
        })
        .then((res) => {
          this.list = res.data.data;
          this.total = res.data.total;
          console.log(res, "987654");
          console.log(this.list, "list的内容");
        });
    },
    //分页
    handleCurrent(v) {
      // console.log(v)
      this.page = v;
      this.indexList();
    },
  },
};
</script>

<style scoped>
.foot {
  margin-top: 20px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
}
.box {
  width: 410px;
  height: 350px;
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  background-color: white;
}
.imgbox {
  width: 100%;
  height: 190px;
}
.imgbox > img {
  width: 100%;
  height: 190px;
}
.content {
  width: 93%;
  height: 130px;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}
.el-tag {
  margin-right: 5px;
}
.tag {
  display: flex;
}
</style>